package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import androidx.appcompat.app.AppCompatActivity;
import easier.app.x.drawable.animator.AnimateProgressDrawable;
import easier.app.x.drawable.progress.load.BallGridPulseDrawable;

public class MainActivity44 extends AppCompatActivity {

    private View mView;
    private SeekBar mSeek;
    private Button mPlay;
    private View mView1;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity44.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main44 );
        initView();
        initViewAction();
    }

    private void initView() {

        mView = (View) findViewById( R.id.view );
        mSeek = (SeekBar) findViewById( R.id.seek );
        mPlay = (Button) findViewById( R.id.play );
        mView1 = (View) findViewById( R.id.view1 );
    }

    private void initViewAction() {

        BallGridPulseDrawable drawable = new BallGridPulseDrawable();
        mView.setBackground( drawable );

        mSeek.setOnSeekBarChangeListener( new OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged( SeekBar seekBar, int i, boolean b ) {

                float v = i / 100f;
                drawable.setProgress( v );
            }

            @Override
            public void onStartTrackingTouch( SeekBar seekBar ) {

            }

            @Override
            public void onStopTrackingTouch( SeekBar seekBar ) {

            }
        } );

        AnimateProgressDrawable animateProgressDrawable = new AnimateProgressDrawable( drawable );
        mView1.setBackground( animateProgressDrawable );
        mPlay.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View view ) {

                animateProgressDrawable.start();
            }
        } );
    }
}